package com.itheima.service;

import com.github.pagehelper.PageHelper;
import com.itheima.domain.Student;
import com.itheima.mapper.StudentMapper;
import com.itheima.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class StudentServiceTest {
  //查询全部
/*@Test
    public void findAll(){
    //1.获取SqlSession对象
    SqlSession sqlSession = MybatisUtils.getSqlSession();
    //2.获取mapper的代理对象
    StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
    //3.调用代理对象方法
    List<Student> list = mapper.findAll();
    for (Student student : list) {
        System.out.println(student);
    }
    sqlSession.close();
}*/

@Test
    public void  findAll(){
    //获取sqlsession对象
    SqlSession sqlSession = MybatisUtils.getSqlSession();
    //获取mapper
    StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
    //调用动态代理方法
    List<Student> studentList = mapper.findAll();
    for (Student student : studentList) {
        System.out.println(student);
       // System.out.println(student.getId()+""+student.getName());
    }
    sqlSession.close();
}


}
